using UnityEngine;
using QFramework;
using UnityEngine.SceneManagement;
using Unity.VisualScripting;

namespace AsterroidX
{
	public partial class UIPause : ViewController,IController
	{
        public IArchitecture GetArchitecture()
        {
            return GameApp.Interface;
        }

        
        private void Start()
        {
            BtnResume.onClick.AddListener(() =>
            {
                this.Hide();
                AudioKit.PlaySound("resources://sfx_click");
            });

            BtnHome.onClick.AddListener(() =>
            {
                BtnHome.onClick.RemoveAllListeners();

                AudioKit.PlaySound("resources://sfx_click");

                ActionKit.ScreenTransition.FadeInOut()
                .OnInFinish(() =>
                {
                    SceneManager.LoadScene("Home");
                }).StartGlobal();

                
            });

            MusicVolumeSlider.onValueChanged.AddListener(value =>
            {
                AudioKit.Settings.MusicVolume.Value = value;
            });

            SoundVolumeSlider.onValueChanged.AddListener(value =>
            {
                AudioKit.Settings.SoundVolume.Value = value;
            });

        }
        private void OnEnable()
        {
            this.SendCommand(new SetPauseCmd(true));
            AudioKit.PauseMusic();

            MusicVolumeSlider.value = AudioKit.Settings.MusicVolume.Value;

            SoundVolumeSlider.value=AudioKit.Settings.SoundVolume.Value;
        }

        private void OnDisable()
        {
            this.SendCommand(new SetPauseCmd(false));
            AudioKit.ResumeMusic();
        }
    }
}
